package com.yiwenup.leetcode.offer;

import java.util.HashSet;
import java.util.Set;

/**
 * https://leetcode-cn.com/problems/bu-ke-pai-zhong-de-shun-zi-lcof/
 **/
public class No061 {
    /**
     * 执行用时：1 ms, 在所有 Java 提交中击败了83.09%的用户
     * 内存消耗：35.9 MB, 在所有 Java 提交中击败了37.33%的用户
     */
    public boolean isStraight(int[] nums) {
        int min = 13;
        int max = 0;
        Set<Integer> set = new HashSet<>();
        for (int num : nums) {
            if (num == 0) continue;
            if (set.contains(num)) return false;
            min = Math.min(min, num);
            max = Math.max(max, num);
            set.add(num);
        }
        return max - min == 4;
    }
}
